#!/usr/bin/env ruby

ip="128.8.126.92"
file=ARGV[0]
#file="data/rtt_trace.full.dat"

f = File.open(file, "r")

old_time = 0
data_sum = 0
interval = 0.01 * 1000000 # 10000 microseconds = 0.01 seconds

f.each_line do |line|
    timestamp,ip_id, s_ip, d_ip, s_port, d_port, seq, ack, win_sz, tot_sz, data_sz   = line.split
    if(s_ip == ip) # The sender is the server. Send a message
        data_sum += data_sz.to_i
        if(timestamp.to_i > old_time + interval)
            print "%d\t%f\n" % [timestamp.to_i, data_sum * 100]
            old_time = timestamp.to_i
            data_sum = 0;
        end
    end
end
